package Utils;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 张
 * Date: 2025-03-08
 * Time: 21:44
 */
//解析日期
public class DataUtil {
    //解析时间格式1
    public static LocalDateTime getData(String dateStr) {
        DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        LocalDate date = LocalDate.parse(dateStr, dateFormatter);

        // 转换为当天的 00:00:00
        LocalDateTime dateTime = date.atStartOfDay();
        return dateTime;
    }

    //解析时间格式2
    public static LocalDateTime getData1(String dateStr) {
        DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm");
        return LocalDateTime.parse(dateStr, dateFormatter);
    }
    //获取当前时间
    public static LocalDateTime getTime() {
        // 获取当前时间
        LocalDateTime now = LocalDateTime.now();
        return now;
    }

}
